package api;

import java.util.ArrayList;
import java.util.List;

public class ListTest {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(10);
        list.add(20);
        list.add(10);
        list.add(30);
        System.out.println(list);//[10, 20, 10, 30]
        //指定位置插入元素
        list.add(0,5);
        System.out.println(list);//[5, 10, 20, 10, 30]
        //返回指定元素的下标
        int i = list.indexOf(30);
        System.out.println(i);//4
        int i1 = list.lastIndexOf(10);
        System.out.println(i1);//3
        //
    }
}
